package com.example.lesson_10_25.service;
import java.util.*;
import com.example.lesson_10_25.mapper.UserMapper;
import com.example.lesson_10_25.pojo.User;
import com.example.lesson_10_25.pojo.VueUser;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @PACKAGE_NAME: com.example.lesson_10_25.service
 * @NAME: UserService
 * @USER: jiang000
 * @DATE: 2023/10/25
 **/
@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;

    public List<User> findUserByName(String name) {
        return userMapper.selectByName(name);
    }
    public User findOnerByName(String name) {
        return userMapper.selectOneUserByName(name);
    }
    public List<User> selectAllUser(){
        return userMapper.selectAllUser();
    }
    public void addUser(VueUser user){
        System.out.println("ADD ");
        userMapper.addUser(user.getUsername(), user.getPassword(), user.getEmail(), user.getRole());
    }

    public void deleteUser(String username ){
        userMapper.deleteUser(username);
    }
    public void resetUserPassword(String username, String password){
        userMapper.resetUserPassword(username, password);
    }
    public void updateUserRole(String username, String role){
        userMapper.updateUserRole(username, role);
    }
    public void updateUserEmail(String username, String email){
        userMapper.updateUserEmail(username, email);
    }
    public void updateUserPassword(String username, String password){
        userMapper.updateUserPassword(username, password);
    }
    public void addUserAndRole(String username, String role_name){
        userMapper.addUserAndRole(username, role_name);
    }

}
